package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointMerchantBank;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Carrot Point 가맹점 결제 은행 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointMerchantBankDaoImpl extends SqlSessionDaoSupport implements CarrotPointMerchantBankDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointMerchantBankDaoImpl.class);

    /**
     * 가맹점 거래 은행을 등록 한다.
     *
     * @param carrotPointMerchantBank
     */
    @Override
    public void registerMerchantBank(CarrotPointMerchantBank carrotPointMerchantBank) {
        logger.info("registerMerchantBank");
        this.getSqlSession().insert("CARROTPOINT_MERCHANT_BANK.registerMerchantBank", carrotPointMerchantBank);
    }

    /**
     * 가맹점 거래 은행 목록을 가져 온다.
     *
     * @param carrotPointMerchantBank
     * @return
     */
    @Override
    public List<CarrotPointMerchantBank> getMerchantBankList(CarrotPointMerchantBank carrotPointMerchantBank) {
        logger.info("getMerchantBankList");
        return this.getSqlSession().selectList("CARROTPOINT_MERCHANT_BANK.getMerchantBankList", carrotPointMerchantBank);
    }

    /**
     * 가맹점 거래 은행 정보를 가져 온다.
     *
     * @param carrotPointMerchantBank
     * @return
     */
    @Override
    public CarrotPointMerchantBank getMerchantBankInformation(CarrotPointMerchantBank carrotPointMerchantBank) {
        logger.info("getMerchantBankInformation");
        return (CarrotPointMerchantBank)getSqlSession().selectOne("CARROTPOINT_MERCHANT_BANK.getMerchantBankInformation", carrotPointMerchantBank);
    }

    /**
     * 가맹점 거래 은행 정보를 업데이트 한다.
     *
     * @param carrotPointMerchantBank
     */
    @Override
    public void updateMerchantBankInformation(CarrotPointMerchantBank carrotPointMerchantBank) {
        logger.info("updateMerchantBankInformation");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_BANK.updateMerchantBankInformation", carrotPointMerchantBank);
    }

    /**
     * 가맹점 거래 은행을 비활성화 한다.
     *
     * @param carrotPointMerchantBank
     */
    @Override
    public void updateDeactivateMerchantBank(CarrotPointMerchantBank carrotPointMerchantBank) {
        logger.info("updateDeactivateMerchantBank");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_BANK.updateDeactivateMerchantBank", carrotPointMerchantBank);
    }
}
